package bg.cinema_system.service;

import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import bg.cinema_system.DAO.UserDAO;
import bg.cinema_system.pojo.Movie;
import bg.cinema_system.pojo.Projection;
import bg.cinema_system.pojo.User;

public class UserServeice {

	public static String converUtilDateToSqlDateString(String utilDate) throws ParseException {
	    Date data = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(utilDate);
	    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	    String sqlDate = sdf.format(data);
	    return sqlDate;
	}
	
	public static User isUserExist(String username, String password)
			throws SQLException {
		return UserDAO.isUserExist(username, password);
	}

	public static boolean createNewUser(User user) throws SQLException {
		return UserDAO.createNewUser(user);
	}

	public static void changePassword(int userId, String password)
			throws SQLException {
		UserDAO.changePassword(userId, password);
	}

	public static boolean checkPassword(int userId, String password)
			throws SQLException {
		return UserDAO.checkPassword(userId, password);
	}

	public static void insertMovie(Movie moviePojo) throws SQLException, ParseException {
		UserDAO.insertMovie(moviePojo);
	}

	public static void insertProjection(Projection projection) throws SQLException, ParseException {
		UserDAO.insertProjection(projection);
		
	}

}
